home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / M2Crypto / PGP / PublicKeyRing.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  3KB  |  73 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from constants import *
  5. from packet import *
  6. from PublicKey import *
  7.  
  8. class PublicKeyRing:
  9.     
  10.     def __init__(self, keyring):
  11.         self._keyring = keyring
  12.         self._userid = { }
  13.         self._keyid = { }
  14.         self._spurious = []
  15.         self._pubkey = []
  16.  
  17.     
  18.     def load(self):
  19.         curr_pub = None
  20.         curr_index = -1
  21.         ps = packet_stream(self._keyring)
  22.         while None:
  23.             pkt = ps.read()
  24.             if pkt is None:
  25.                 break
  26.                 continue
  27.             None if isinstance(pkt, public_key_packet) else curr_pub is None
  28.             if isinstance(pkt, signature_packet):
  29.                 if curr_pub is None:
  30.                     self._spurious.append(pkt)
  31.                 else:
  32.                     curr_pub.add_signature(pkt)
  33.             curr_pub is None
  34.             self._spurious.append(pkt)
  35.             continue
  36.             ps.close()
  37.             return None
  38.  
  39.     
  40.     def __getitem__(self, id):
  41.         return self._userid[id][0]
  42.  
  43.     
  44.     def __setitem__(self, *args):
  45.         raise NotImplementedError
  46.  
  47.     
  48.     def __delitem__(self, id):
  49.         (pkt, idx) = self._userid[id]
  50.         del self._pubkey[idx]
  51.         del self._userid[idx]
  52.         (pkt, idx) = self._keyid[id]
  53.         del self._keyid[idx]
  54.  
  55.     
  56.     def spurious(self):
  57.         return tuple(self._spurious)
  58.  
  59.     
  60.     def save(self, keyring):
  61.         for p in self._pubkey:
  62.             pp = p.pack()
  63.             keyring.write(pp)
  64.         
  65.  
  66.  
  67.  
  68. def load_pubring(filename = 'pubring.pgp'):
  69.     pkr = PublicKeyRing(open(filename, 'rb'))
  70.     pkr.load()
  71.     return pkr
  72.  
  73.